export const schema = {
    type: "page",
    title: "我的志愿者",
    body: {
        type: "crud",
        api: "/api/volunteer",
        primaryField: 'user_id',
        columnsTogglable: false,
        filter: {
            title: "",
            submitText: "",
            panelClassName: 'm-b-none bg-gd no-border',
            bodyClassName: 'wrapper-sm',
            controls: [
                {
                    type: "select",
                    name: "group_id",
                    label: "分组类型",
                    source: "/api/group_name",
                    clearable: true
                },
                {
                    type: "text",
                    name: "keyword",
                    placeholder: "用户名、联系电话、证件号码",
                    width: 260
                },
                {
                    type: 'button-toolbar',
                    buttons: [
                        {
                            type: "submit",
                            label: "搜索",
                            primary: true
                        },

                        {
                            type: "button",
                            label: "导出成员",
                            level: "info",
                            actionType: "url",
                            url: "/api/volunteer?asExcel=1&keyword=${keyword}"
                        }
                    ]
                }
            ]
        },
        bulkActions: [
            {
                type: "button",
                label: "通知",
                actionType: "dialog",
                level: "info",
                dialog: {
                    title: "发送站内信",
                    body: {
                        type: "form",
                        api: 'post:/api/volunteer/notify/${ids}',
                        controls: [
                            {
                                type: "textarea",
                                name: "content",
                                label: false
                            }
                        ]
                    }
                }
            },
            {
                type: "button",
                label: "删除成员",
                actionType: "ajax",
                level: "danger",
                api: "delete:/api/volunteer/${ids}",
                confirmText: '确定要移除指定用户吗？'
            },
            {
                type: "button",
                label: "成员分组",
                actionType: "dialog",
                level: "info",
                dialog: {
                    title: "选择分组",
                    body: {
                        type: "form",
                        api: 'post:/api/user_group/add/${ids}',
                        controls: [
                            {
                                type: "select",
                                name: "volunteer_group_id",
                                label: "分组类型",
                                source: "/api/group_name?sd={$id}",
                                required: true,
                                clearable: true
                            }
                        ]
                    }
                }
            },
        ],
        columns: [
            {
                name: "id",
                label: "志愿者ID",
                width: 50
            },
            {
                label: "姓名",
                name: 'real_name',
                type: "tpl",
                // tpl: "<a data-link='/volunteer/view/${id}'>${real_name}</a>"
                tpl: "<a data-link='/volunteer/view/${data.id}'><%= data.real_name ? data.real_name : '-' %></a> "
            },
            {
                label: "用户名",
                name: 'username',
                type: "tpl",
                // tpl: "<a data-link='/volunteer/view/${id}'>${real_name}</a>"
                tpl: "<a data-link='/volunteer/view/${data.id}'><%= data.username ? data.username : '-' %></a> "
            },
            {
                label: "积分",
                name: 'score'
            },
            {
                label: "性别",
                name: 'sex',
                type: 'map',
                map: {
                    '1': '男',
                    '2': '女'
                }
            },
            {
                label: "年龄",
                name: 'age'
            },
            {
                label: "联系电话",
                name: 'phone'
            },
            {
                label: "居住区域",
                innerClassName: 'w',
                type: "tpl",
                tpl: "${province_name} ${city_name} ${county_name} ${addr}"
            },
            {
                label: "参与项目数",
                name: 'project_count'
            },
            {
                label: "志愿时长",
                name: 'reward_time'
            },
            {
                label: "注册时间",
                name: "created_at",
                type: 'tpl',
                tpl: "${created_at|date:LL:YYYY-MM-DD HH:mm:ss}"
            }
        ]
    }
};
